import Vue from 'vue'
import VueRouter from 'vue-router'
import Background from "@/Background";
import Login from "@/views/login_register/Login"
import Register from "@/views/login_register/Register";

import Home from "@/views/home/Home";
import Index from "@/views/home/home_page/Index"

import CommodityManagement from "@/views/restaurant/merchant/CommodityManagement";

import RestaurantInformation from "@/views/user/restaurant_information/RestaurantInformation"
import CommodityInformation from "@/views/user/restaurant_information/CommodityInformation";
import UserCenter from "@/views/user/drop_down/UserCenter";
import MyWallet from "@/views/user/drop_down/MyWallet";
import ShoppingRecord from "@/views/user/shopping/ShoppingRecord";
import MyComment from "@/views/user/comment/MyComment";
import ShoppingCart from "@/views/user/shopping/ShoppingCart";
import CommodityComments from "@/views/restaurant/comment/CommodityComments";
import CommodityCommentsList from "@/views/restaurant/comment/CommodityCommentsList";
import OrderManagement from "@/views/restaurant/merchant/OrderManagement";
import RiderOrderManagement from "@/views/rider/management/RiderOrderManagement";
import GeneralHome from "@/views/website/home/GeneralHome";
import Commodity from "@/views/website/restaurant/Commodity";
import RestaurantWebsiteInformation from "@/views/website/restaurant/RestaurantWebsiteInformation";
import CommodityWebsiteInformation from "@/views/website/restaurant/CommodityWebsiteInformation";
import AdministrationHome from "@/views/administration/home/AdministrationHome";
import AdministrationAudit from "@/views/administration/audit/AdministrationAudit";
import AdministrationAuditUser from "@/views/administration/audit/AdministrationAuditUser";
import AdministrationAuditCommodity from "@/views/administration/audit/AdministrationAuditCommodity";
import AdministratorCommodity from "@/views/administration/commodity/AdministratorCommodity";
import AdministratorUser from "@/views/administration/user/AdministratorUser";
import AdministratorPlatform from "@/views/administration/platform/AdministratorPlatform";
import Atlas from "@/views/home/home_page/Atlas";


Vue.use(VueRouter)


const router = new VueRouter({
  /**
   * mode：路由模式
   * 'hash'：路径带#号（http://localhost/#/login）
   * 'history'：路径不带#号（http://localhost/login）
   */
  mode: 'history',

  routes: [ 
    /**
     * 背景页面
     */
    {
      path: "/background",
      name: "background",
      component: Background,
      meta: {
        title: "背景"
      }
    },

    /**
     * 登录页面
     */
    {
      path:"/login",
      name:"login",
      component:Login,

      /**
       * meta字段（元数据）：直接在路由配置的时候，给每个路由添加一个自定义的meta对象，在meta对象中可以设置一些状态，用来做登录验证
       */
      meta: {
        title: "登录"
      }
    },

    /**
     * 注册页面
     */
    {
      path: "/register",
      name: "register",
      component: Register,
      meta: {
        title: "注册"
      }
    },

    /**
     * 主页面（登录之后显示的页面）
     */
    {
      path: "/home",
      name: "home",
      redirect: "/index",
      component: Home,
      children: [
        /**
         * 首页（展示美食）
         */
        {
          path: "/index",
          name: "Index",
          component: Index,
          meta:{
            title: "首页"
          }
        },

        /**
         * 地图显示餐厅信息
         */
        {
          path: "/atlas",
          name:"atlas",
          component: Atlas,
          meta:{
            title: "地图显示餐厅信息"
          }
        },

        /**
         * 用户中心页面（商家和用户共用）
         */
        {
          path: "/index/userCenter",
          name: "userCenter",
          component: UserCenter,
          meta: {
            title: "用户中心页面"
          }
        },
        /**
         * 我的钱包页面
         */
        {
          path: "/index/myWallet",
          name: "MyWallet",
          component: MyWallet,
          meta: {
            title: "我的钱包页面"
          }
        },

        /**
         * 美食管理页面（商家）
         */
        {
          path: "/index/commodityManagement",
          name: "CommodityManagement",
          component: CommodityManagement,
          meta: {
            title: "商品管理"
          }
        },

        /**
         * 美食评论页面（商家）
         */
        {
          path: "/index/commodityComments",
          name: "CommodityComments",
          component: CommodityComments,
          meta: {
            title: "商品评论"
          }
        },
        /**
         * 美食评论列表（商家）
         */
        {
          path: "/index/commodityComments/commodityCommentsList/:commodityId/:commodityName",
          name: "commodityCommentsList",
          component: CommodityCommentsList,
          props:true,
          meta: {
            title: "美食评论列表"
          },
        },

        /**
         * 订单管理页面（商家）
         */
        {
          path: "/index/orderManagement",
          name: "OrderManagement",
          component: OrderManagement,
          meta: {
            title: "订单管理"
          }
        },

        /**
         * 餐厅具体信息页面（用户）
         */
        {
          path:"/index/restaurantInformation/:id/:restaurantName",
          name:"restaurantInformation",
          component:RestaurantInformation,
          props:true,
          meta:{
            title:"餐厅信息"
          }
        },
        /**
         * 美食具体信息页面（用户）
         */
        {
          path:"/index/commodityInformation/:commodityId/:restaurantId/:restaurantName",
          name:"commodityInformation",
          component:CommodityInformation,
          props:true,
          meta:{
            title:"美食信息"
          }
        },
        /**
         * 用户购买记录页面
         */
        {
          path: "/index/shoppingRecord",
          name: "ShoppingRecord",
          component: ShoppingRecord,
          meta: {
            title: "购买记录"
          }
        },
        /**
         * 购物车页面
         */
        {
          path: "/index/shoppingCart",
          name: "ShoppingCart",
          component: ShoppingCart,
          meta: {
            title: "购物车页面"
          }
        },
        /**
         * 用户评论列表
         */
        {
          path: "/index/myComment",
          name: "MyComment",
          component: MyComment,
          meta: {
            title: "我的评论"
          }
        },

        /**
         * 订单管理页面（骑手）
         */
        {
          path: "/index/riderOrderManagement",
          name: "RiderOrderManagement",
          component: RiderOrderManagement,
          meta: {
            title: "订单管理"
          }
        },
      ]
    },

    /**
     * 餐厅门户页面
     */
    {
      path: "/general",
      name: "general",
      component: GeneralHome,
      children:[
        /**
         * 餐厅门户首页
         */
        {
          path: "commodity",
          name: "generalCommodity",
          component: Commodity,
          meta: {
            title: "餐厅门户首页"
          },
        },

        /**
         * 餐厅具体信息
         */
        {
          path:"restaurantWebsiteInformation",
          name:"restaurantWebsiteInformation",
          props:true,
          component:RestaurantWebsiteInformation,
          meta:{
            title:"餐厅具体信息"
          }
        },

        /**
         * 餐厅中美食的具体信息
         */
        {
          path:"commodityWebsiteInformation",
          name:"commodityWebsiteInformation",
          props:true,
          component:CommodityWebsiteInformation,
          meta:{
            title:"餐厅中美食的具体信息"
          }
        }
      ]
    },

    /**
     * 管理员页面
     */
    {
      path:"/administration",
      name:"administration",
      component:AdministrationHome,
      redirect:"/administration/audit",
      children:[
        {
          path:"audit",
          name:"audit",
          component: AdministrationAudit,
          meta: {
            title: "管理员首页"
          },
          children:[
            /**
             * 用户信息审核页面
             */
            {
              path:"user",
              name:"user",
              component:AdministrationAuditUser,
              meta:{
                title:"用户信息审核页面"
              }
            },

            /**
             * 美食信息审核页面
             */
            {
              path:"commodity",
              name:"commodity",
              component:AdministrationAuditCommodity,
              meta:{
                title:"美食信息审核页面"
              }
            },
          ]
        },

        /**
         * 美食管理
         */
        {
          path: "commodity",
          name: "administrationCommodity",
          component: AdministratorCommodity,
          meta: {
            title: "美食管理"
          }
        },

        /**
         * 用户管理
         */
        {
          path:"user",
          name:"administrationUser",
          component:AdministratorUser,
          meta:{
            title:"用户管理"
          }
        },

        /**
         * 平台管理
         */
        {
          path:"platform",
          name:"administrationPlatform",
          component: AdministratorPlatform,
          meta:{
            title:"平台管理"
          }
        }
      ]
    }
  ]
})

export default router
